import request from '@/utils/request'

// 快递员渲染
export function getdeltList(params) {
  return request({
    url: '/manager/business-hall/courier/page',
    method: 'get',
    params
  })
}

// 树状结构信息
export function treeList(params) {
  return request({
    url: '/manager/business-hall/tree',
    method: 'get',
    params
  })
}

// 搜索快递员

export function searchAPI(agencyId) {
  return request({
    url: `/manager/business-hall/courier/findByAgencyId/${agencyId}`,
    method: 'get',
    params: {
      id: agencyId
    }
  })
}

// 定义一个递归函数，在树状数组中查找目标值所在的对象export
export function findObjectByValue(obj, targetValue) {
  if (obj.value === targetValue) {
    return obj
  }

  for (var i = 0; i < obj.children.length; i++) {
    var child = obj.children[i]
    var foundObject = findObjectByValue(child, targetValue)

    if (foundObject) {
      return foundObject
    }
  }

  return null
}
